<template>
  <div class="tap-control">
    <div
      v-for="(item, index) in titles"
      class="tap-control-item"
      :class="{ active: index === curentindex }"
      @click="itemclick(index)"
    >
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TapControl",
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      curentindex: 0,
    };
  },
  methods: {
    itemclick(index) {
      this.curentindex = index;
      this.$emit("tapclick", index);
    },
  },
};
</script>

<style scoped>
.tap-control {
  display: flex;
  width: 100%;
  text-align: center;
  font-size: 4vw;
  line-height: 8vw;
  height: 8vw;
  background: #696969;
  color: #fff;
  position: sticky;
  top: 14vw;
}
.tap-control-item {
  display: flex;
  display: flex;
  flex-direction: column;
  width: 100%;
  border: 1px solid #333333;
  cursor: pointer;
}
.active {
  font-weight: bold;
  background-color: #778899;
}
</style>